Disentangle ForwardGenericParamBan and ConstParamTy ribs#138259
Merged
bors merged 1 commit intorust-lang:masterfrom Mar 13, 2025
Merged
Disentangle ForwardGenericParamBan and ConstParamTy ribs#138259bors merged 1 commit intorust-lang:masterfrom
ForwardGenericParamBan and ConstParamTy ribs#138259bors merged 1 commit intorust-lang:masterfrom
Conversation
Member
|
ah right 🤔 I guess at the time I thought that params would include all params in scope but that doesnt make any sense xd |
Member
#![feature(adt_const_params)]
trait Trait<const N: usize> {
fn foo<const M: [u8; N]>() {}
}Can you add a test that we forbid this? Apparently we don't have such a test already ^^' |
7cf39de to
ea88485
Compare
This comment has been minimized.
This comment has been minimized.
ea88485 to
a79f97b
Compare
Collaborator
|
This PR changes a file inside |
Member
|
@bors r+ this is much nicer now thx |
Collaborator
jieyouxu
added a commit
to jieyouxu/rust
that referenced
this pull request
Mar 12, 2025
…r=BoxyUwU Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs In rust-lang#137617, the `ConstParamTy` rib was adjusted to act kinda like the `ForwardGenericParamBan`. However, this means that it no longer served its purpose banning generics from *parent items*. Although we still are checking for param type validity using the `ConstParamTy_` trait, which means that we weren't accepting code we shouldn't, I think it's a bit strange for us not to be rejecting code like this during *resolution* and instead letting these malformed const generics leak into the type system: ```rust trait Foo<T> { fn bar<const N: T>() {} } ``` This PR does a few things: 1. Introduce a `ForwardGenericParamBanReason` enum, and start using the `ForwardGenericParamBan` rib to ban forward-declared params in const tys when `generic_const_parameter_types` is enabled. 2. Start using the `ConstParamTy` rib to ban *all* generics when `generic_const_parameter_types` is disabled. 3. Improve the diagnostics for both of the cases above, and for forward-declared params in parameter defaults too :3 r? `@BoxyUwU` or reassign
Member
|
I think this failed in rollup: #138382 (comment) @bors r- |
Member
|
gamer |
This comment has been minimized.
This comment has been minimized.
a79f97b to
42773bf
Compare
Contributor
Author
|
@bors r=BoxyUwU |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 12, 2025
…earth Rollup of 12 pull requests Successful merges: - rust-lang#134076 (Stabilize `std::io::ErrorKind::InvalidFilename`) - rust-lang#137504 (Move methods from Map to TyCtxt, part 4.) - rust-lang#138175 (Support rmeta inputs for --crate-type=bin --emit=obj) - rust-lang#138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs) - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`) - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js) - rust-lang#138331 (Use `RUSTC_LINT_FLAGS` more) - rust-lang#138357 (merge `TypeChecker` and `TypeVerifier`) - rust-lang#138394 (remove unnecessary variant) - rust-lang#138403 (Delegation: one more ICE fix for `MethodCall` generation) - rust-lang#138407 (Delegation: reject C-variadics) - rust-lang#138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX) r? `@ghost` `@rustbot` modify labels: rollup
Contributor
Author
|
@bors rollup |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 13, 2025
…earth Rollup of 12 pull requests Successful merges: - rust-lang#134076 (Stabilize `std::io::ErrorKind::InvalidFilename`) - rust-lang#137504 (Move methods from Map to TyCtxt, part 4.) - rust-lang#138175 (Support rmeta inputs for --crate-type=bin --emit=obj) - rust-lang#138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs) - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`) - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js) - rust-lang#138331 (Use `RUSTC_LINT_FLAGS` more) - rust-lang#138357 (merge `TypeChecker` and `TypeVerifier`) - rust-lang#138394 (remove unnecessary variant) - rust-lang#138403 (Delegation: one more ICE fix for `MethodCall` generation) - rust-lang#138407 (Delegation: reject C-variadics) - rust-lang#138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX) r? `@ghost` `@rustbot` modify labels: rollup
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this pull request
Mar 14, 2025
…earth Rollup of 12 pull requests Successful merges: - rust-lang#134076 (Stabilize `std::io::ErrorKind::InvalidFilename`) - rust-lang#137504 (Move methods from Map to TyCtxt, part 4.) - rust-lang#138175 (Support rmeta inputs for --crate-type=bin --emit=obj) - rust-lang#138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs) - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`) - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js) - rust-lang#138331 (Use `RUSTC_LINT_FLAGS` more) - rust-lang#138357 (merge `TypeChecker` and `TypeVerifier`) - rust-lang#138394 (remove unnecessary variant) - rust-lang#138403 (Delegation: one more ICE fix for `MethodCall` generation) - rust-lang#138407 (Delegation: reject C-variadics) - rust-lang#138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX) r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #137617, the
ConstParamTyrib was adjusted to act kinda like theForwardGenericParamBan. However, this means that it no longer served its purpose banning generics from parent items. Although we still are checking for param type validity using theConstParamTy_trait, which means that we weren't accepting code we shouldn't, I think it's a bit strange for us not to be rejecting code like this during resolution and instead letting these malformed const generics leak into the type system:This PR does a few things:
ForwardGenericParamBanReasonenum, and start using theForwardGenericParamBanrib to ban forward-declared params in const tys whengeneric_const_parameter_typesis enabled.ConstParamTyrib to ban all generics whengeneric_const_parameter_typesis disabled.r? @BoxyUwU or reassign